package com.lvmama.rhino.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.rhino.entity.PushConditionVO;
import com.lvmama.rhino.mapperHippo.PushMapper;
import com.lvmama.rhino.pojo.PushData;
import com.lvmama.rhino.pojo.PushReturn;
import com.lvmama.rhino.service.PushService;


/**
 * 说明：
 * @author yecan
 * @date 2016年7月7日
 */
@Service
public class PushServiceImpl implements PushService{

	@Autowired
	private PushMapper pushMapper;
	
	@Override
	public PushReturn queryPushData(PushConditionVO pushConditionVO,
			Date startTime, Date endTime) {
		String pushObject = pushConditionVO.getPushObject();
		String pushID = pushConditionVO.getPushID();
		String pushTerminal = pushConditionVO.getPushTerminal();
		PageHelper.startPage(pushConditionVO.getPageNum(), pushConditionVO.getPageSize());
		 List<PushData> list=pushMapper.queryPushData(pushObject,pushID,"%,"+pushID+",%",pushID+",%","%,"+pushID,pushTerminal,startTime,endTime);
		 PageInfo<PushData> pageInfo=new PageInfo<PushData>(list);
		 PushReturn pushReturn=new PushReturn();
		 pushReturn.setCount(pageInfo.getTotal());
		 pushReturn.setPushList(pageInfo.getList());
		 pushReturn.setPageInfo(pageInfo);
		 pushReturn.setPageBar();
		 pushReturn.setPushListSize(list.size());
		 return pushReturn;
	}

	
	@Override
	public List<PushData> exportPushData(PushConditionVO pushConditionVO,
			Date startTime, Date endTime) {
		String pushObject = pushConditionVO.getPushObject();
		String pushID = pushConditionVO.getPushID();
		String pushTerminal = pushConditionVO.getPushTerminal();
		 List<PushData> list=pushMapper.queryPushData(pushObject,pushID,"%,"+pushID+",%",pushID+",%","%,"+pushID,pushTerminal,startTime,endTime);
		return list;
	}

}
